package com.qijia.travel.helper;

import java.io.IOException;
import java.util.Properties;
import javax.servlet.http.HttpServlet;
public class Log4jHelper extends HttpServlet{

	    /**
	 * 
	 */
	private static final long serialVersionUID = 8897076631722966703L;

		public void init() {
	        /**
			 * apache中的调用方法 String prefix =getServletContext().getRealPath("/");
			 * 
			 * String file = getInitParameter("log4j"); // if the
			 * log4j-init-file is not set, then no point in trying
			 * 
			 * System.out.println("................log4j start");
			 * 
			 * if(file != null) {
			 * 
			 * PropertyConfigurator.configure(prefix+file); }
			 * 
			 */
	         String file = getInitParameter("log4j");        
	         System.out.println("................log4j start file:"+file);
	         
	        if (file != null) {
	             Properties ps=new Properties();
	            try {
	                 ps.load(getServletContext().getResourceAsStream(file));
	             } catch (IOException e) {
	                 e.printStackTrace();
	             }
	         }
	    }
}
